package cn.smbms.service.provider;

import cn.smbms.dao.provider.ProviderMapper;
import cn.smbms.pojo.Provider;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("providerService")
public class ProviderServiceImpl implements ProviderService {
    @Resource
    private ProviderMapper providerMapper;

    //通过供应商名称、编码获取供应商列表-模糊查询-providerList
    @Override
    public List<Provider> getProviderList(String proName, String proCode, int currentPageNo, int pageSize) {
        int beginIndex = (currentPageNo-1) * pageSize;
        return providerMapper.getProviderList(proName, proCode, beginIndex,pageSize);
    }

    @Override
    public int getProviderCount(String proName, String proCode) {
        return providerMapper.getProviderCount(proName,proCode);
    }

    @Override
    public boolean add(Provider provider) {
        return  providerMapper.add(provider) > 0;
    }

    @Override
    public Provider getProviderById(Integer id) {
        return providerMapper.getProviderById(id);
    }

    @Override
    public boolean update(Provider provider) {
        return providerMapper.update(provider) > 0;
    }
}
